-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Stats: PeriodStore + improve CoreData Persistence + Caching #19776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
You can test the changes in Jetpack from this Pull Request by:
|
You can test the changes in WordPress from this Pull Request by:
|
|
@sla8c , I looked at this change and I agree with you that it makes perfect sense. I also tried to understand why it might not be working. I found that This is a quick change that I made to After this change, the block is triggered: |
|
@staskus as discussed I've pushed a change for this using DispatchGroups and its ready for review. Thanks! 🙇 |
staskus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guarani let me know if you'd like to review as well.
I'll wait for your take. We can make any improvements if needed ourselves.
guarani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix works great! I found I verified that after the app gets new Stats data for Views, it uses that on subsequent loads of the Stats page.
I'm not sure about a couple of things:
- Is saving to core data only needed when the feature flag is on (and not when it's off)?
- Is saving to core data even when there's an error fetching the data the right choice?
I'll come back to this to finish digging into these questions.
If we don't add Feature Flags, we would make this functionality available for the non-revamped version of Stats as well. I tested and I don't see a problem with that, outside the fact that this improvement then could get shipped before the actual revamped stats.
No issues happen because of that but there's a bit of inefficiency. If an error happens for all the calls, then there's no change in data in the If an error happens for one or two of the calls and the others succeed then we're correct to persist data. |
staskus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving this PR since the functionality works for me and the usage of DispatchGroup in this scenario is understandable.
As I explained in the previous comment: usage of FeatureFlag could potentially be optional and I don't see any issues that could come with persisting data if some of the calls fail.
|
Merging with one approval. Since the functionality is left under the feature flag it's safe to merge. |

This PR adds functionality to fix a caching issue in the PeriodStore
The StatsPeriodStore has a note on how the persist to CoreData has an unintuitive call. And after diving deeply + trying to diagnose I can see that at the tail end of fetchAsyncData no further saves to CoreData are called
Attempted solution 1
I've tried to fix this by adding a barrierblock as the last operation to fetchAsyncData but at this time that is still not working so I've left this in draft statusNote that all the other fetch calls in StatsPeriodStore also save to core data ie: fetchAllVideos, fetchAllSearchTerms etc so I'm not sure why fetchAsyncData did not have this as well and cannot see why it shouldn't have (this call)Attempted solution 2
The barrierblock solution was discarded in favor of using dispatch groups to save to core data once multiple fetches have completed.
Fixes #19430
These should be the steps for a successful test (same as in the issue)
Regression Notes
Potential unintended areas of impact
Stats
What I did to test those areas of impact (or what existing automated tests I relied on)
Manual testing
What automated tests I added (or what prevented me from doing so)
PR submission checklist:
RELEASE-NOTES.txtif necessary.